#!/bin/sh

ROOT_PATH=/home/web/framework

#searchd 运行后生成的pid file，注意：要同csft config文件一样
SEARCHD_PID_FILE=${ROOT_PATH}/logs/coreseek/searchd_mysql.pid
DAEMON_LOG=${ROOT_PATH}/logs/coreseek/daemon.log

#${ROOT_PATH}/coreseek.sh start > ${ROOT_PATH}/coreseek.log 2>&1 &
#sleep 5 

while [ 1 ]
do
    if [ ! -f ${SEARCHD_PID_FILE} ]; then
        ${ROOT_PATH}/backend/coreseek/coreseek.sh start >> ${DAEMON_LOG} 2>&1 &
        sleep 5
        echo `date` restart coreseek service... >> ${DAEMON_LOG}
        echo pid: `cat ${SEARCHD_PID_FILE}` >> ${DAEMON_LOG}  
        echo "Subject: framework coreseek is restarted at `date`" | sendmail jackzhou@nmg.com.hk,terrywu@nmg.com.hk
    fi

    sleep 10
done
